<template>
	<view class="container" :style="{height:`calc(100vh - ${height}px)`}">
		<Header title="活动日历" back></Header>
		<view class="wapper">
			<template v-if="contents.length > 0">
				<view class="content-item" v-for="(v,k) in contents" :key="k" @click="toDetail(v)">
					<div class="title">{{v.title}}</div>
					<div class="desc" v-html="v.content"> </div>
					<div class="date">{{v.beginTime}} - {{v.endTime}}</div>
					<!-- <view class="bottom">
						<view class="bottom-title">
							{{v.title}}
						</view>
						<view class="bottom-date">
							{{v.addDate}}
						</view>
					</view> -->
				</view>
			</template>
			<u-empty v-else descript="暂无数据" style="margin: 0 auto;"></u-empty>
		</view>
	</view>
</template>

<script>
	import Header from '@/components/haeder.vue'
	import banner1 from '@/static/banner/banner1.png'
	export default {
		components: {
			Header
		},
		data() {
			return {
				height: 0,
				searchParams: {
					siteId: 12,
					channelId: 16,
					page: 1,
					perPage: 999,
					order: [{
						desc: true
					}]
				},
				contents: [],
				total: 0,
				status: 0
			}
		},
		methods: {
			toDetail(v) {
				
				const str = encodeURIComponent(JSON.stringify({
					head: v.title ,
					content: v.content
				}))
				uni.navigateTo({
					url: "../index/detail?title=活动详情&data=" + str
				})
			},
			async search() {
				let res = await this.$api.getNavs4(this.searchParams)
				this.contents = res.contents
				this.total = res.totalCount
			}
		},
		async mounted() {
			this.search()
		},
		created() {
			let app = uni.getSystemInfoSync();
			this.height = app.windowBottom
		}
	}
</script>

<style scoped lang="scss">
	.container {
		width: 100vw;
		overflow: auto;
		display: flex;
		flex-direction: column;

		.wapper {
			flex: 1;
			background: #f2f2f2;
			padding: 20rpx;
			z-index: 100;
			margin-top: -280rpx;
			border-top-left-radius: 60rpx;
			border-top-right-radius: 60rpx;

			.content-item {
				margin: 20rpx 0;
				border-radius: 20rpx;
				background: #fff;
				box-shadow: 4rpx 4rpx 8rpx rgba(0, 0, 0, 0.08);
				padding: 40rpx  20rpx;
				display: flex;
				flex-direction: column;
				justify-content: space-around;
				color: #404040;

				.title {
					font-size: 36rpx;
				}

				.date {
					font-size: 24rpx;
					color: #787878;
				}

				.desc {
					margin: 40rpx 0;
					text-indent: 2em;
					overflow: hidden; //超出文本隐藏
					text-overflow: ellipsis; //溢出显示省略号
					display: -webkit-box; //设置为弹性盒子
					-webkit-box-orient: vertical;
					-webkit-line-clamp: 2
				}
			}
		}
	}
</style>